package idv.loveloser.servlet;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

import java.io.File;


public class SystemSets {
	private static final Properties systemProp = new Properties();
	static{
		try {
			File setFile=new File("./system.prop");
			System.out.println("Set File is :"+setFile.getAbsoluteFile());
			systemProp.load(new FileInputStream(setFile));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			SystemSets.setSalt("b;p6wP&{#9:*gQD5+K?O#k`e");
			SystemSets.setStorage("/var/www/moodledata/filedir");
			systemProp.put("file.separator", System.getProperty("file.separator"));
		} 
		
	}
	public static final String getSalt(){
		return systemProp.getProperty("salt");
	}
	public static final String getStorage(){
		return systemProp.getProperty("storage");
	}
	public static void setSalt(String salt){
		systemProp.setProperty("salt", salt);
		try {
			systemProp.store(new FileOutputStream("./system.prop"), "");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void setStorage(String storage){
		systemProp.setProperty("storage", storage);
		try {
			systemProp.store(new FileOutputStream("./system.prop"), "");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static String getFileSeperator(){
		return systemProp.getProperty("file.separator");
	} 
//	public static final void main(String[] argcs){
//		SystemSets.setSalt("b;p6wP&{#9:*gQD5+K?O#k`e");
//		SystemSets.setStorage("/var/www/moodledata/filedir/");
//	}
}
